Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the issue of misaligned comments after formatting #40

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

wugeer
Copy link
Contributor

@wugeer wugeer commented Aug 22, 2024

input text:

    -- 创建一个外部表,存储销售数据
CREATE EXTERNAL TABLE IF NOT EXISTS sales_data (
    -- 唯一标识订单ID
    order_id BIGINT COMMENT 'Unique identifier for the order',
    
    -- 客户ID
    customer_id BIGINT COMMENT 'Unique identifier for the customer'
)
COMMENT 'Sales data table for storing transaction records';

-- 按销售日期和城市进行分区
PARTITIONED BY (
    sale_year STRING COMMENT 'Year of the sale',
    sale_month STRING COMMENT 'Month of the sale'
)

-- 设置数据存储位置
LOCATION '/user/hive/warehouse/sales_data'

-- 使用 ORC 存储格式
STORED AS ORC

-- 设置表的行格式
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'

-- 设置表属性
TBLPROPERTIES (
    'orc.compress' = 'SNAPPY',          -- 使用SNAPPY压缩
    'transactional' = 'true',           -- 启用事务支持
    'orc.create.index' = 'true',        -- 创建索引
    'skip.header.line.count' = '1',     -- 跳过CSV文件的第一行
    'external.table.purge' = 'true'     -- 在删除表时自动清理数据
);

-- 自动加载数据到 Hive 分区中
ALTER TABLE sales_data
ADD PARTITION (sale_year = '2024', sale_month = '08')
LOCATION '/user/hive/warehouse/sales_data/2024/08';

before output:

-- 创建一个外部表,存储销售数据
CREATE EXTERNAL TABLE IF NOT EXISTS sales_data (
    -- 唯一标识订单ID
    order_id BIGINT COMMENT 'Unique identifier for the order',
    -- 客户ID
    customer_id BIGINT COMMENT 'Unique identifier for the customer'
) COMMENT 'Sales data table for storing transaction records';
-- 按销售日期和城市进行分区
PARTITIONED BY (
    sale_year STRING COMMENT 'Year of the sale',
    sale_month STRING COMMENT 'Month of the sale'
) -- 设置数据存储位置
LOCATION '/user/hive/warehouse/sales_data' -- 使用 ORC 存储格式
STORED AS ORC -- 设置表的行格式
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' -- 设置表属性
TBLPROPERTIES (
    'orc.compress' = 'SNAPPY',
    -- 使用SNAPPY压缩
    'transactional' = 'true',
    -- 启用事务支持
    'orc.create.index' = 'true',
    -- 创建索引
    'skip.header.line.count' = '1',
    -- 跳过CSV文件的第一行
    'external.table.purge' = 'true' -- 在删除表时自动清理数据
);
-- 自动加载数据到 Hive 分区中
ALTER TABLE
    sales_data
ADD
    PARTITION (sale_year = '2024', sale_month = '08') LOCATION '/user/hive/warehouse/sales_data/2024/08';

alfter fix output

-- 创建一个外部表,存储销售数据
CREATE EXTERNAL TABLE IF NOT EXISTS sales_data (
    -- 唯一标识订单ID
    order_id BIGINT COMMENT 'Unique identifier for the order',
    -- 客户ID
    customer_id BIGINT COMMENT 'Unique identifier for the customer'
) COMMENT 'Sales data table for storing transaction records';
-- 按销售日期和城市进行分区
PARTITIONED BY (
    sale_year STRING COMMENT 'Year of the sale',
    sale_month STRING COMMENT 'Month of the sale'
)
-- 设置数据存储位置
LOCATION '/user/hive/warehouse/sales_data'
-- 使用 ORC 存储格式
STORED AS ORC
-- 设置表的行格式
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
-- 设置表属性
TBLPROPERTIES (
    'orc.compress' = 'SNAPPY',  -- 使用SNAPPY压缩
    'transactional' = 'true',  -- 启用事务支持
    'orc.create.index' = 'true',  -- 创建索引
    'skip.header.line.count' = '1',  -- 跳过CSV文件的第一行
    'external.table.purge' = 'true' -- 在删除表时自动清理数据
);
-- 自动加载数据到 Hive 分区中
ALTER TABLE
    sales_data
ADD
    PARTITION (sale_year = '2024', sale_month = '08') LOCATION '/user/hive/warehouse/sales_data/2024/08';

Copy link
Owner

@shssoichiro shssoichiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor Author

@wugeer wugeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good test!

@shssoichiro shssoichiro merged commit 78f24a6 into shssoichiro:master Aug 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants